<?php
/**
 * @author ai|deeFlow
 */
namespace Engine\Functions;

class FileSystem {
    
    public static function getDirectoriesList($outerDir, $filters = array()) {
        
        return array_diff(scandir($outerDir), array_merge(array(".", "..")), $filters);
    } 

    public static function getDirectoryTree($outerDir, $onlyRootDirNames, $filters = array()){

    $dirs = array_diff(scandir($outerDir), array_merge(array(".", ".."), $filters));

        $dir_array = array();
        foreach($dirs as $element){
            $dir_array[$element] = is_dir($outerDir."/".$element) ? self::getDirectoryTree( $outerDir."/".$element, $filters ) : $dir_array[ $element ] = $element;
        }

        if (!$onlyRootDirNames){
            return $dir_array;
        }else{
            $tmpDirs = array();

            foreach ($dir_array as $key => $value) {
                 $tmpDirs[]=$key;
            }

            return $tmpDirs;
        }
}

    
}

?>
